home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 43 / Mac Magazin and MacEasy Magazine CD - Issue 43.iso / Software / Multimedia / Sound / PlayerPRO 4.6 Dev.Kit / MADH Library 4.6 / MADLibrary Source / AWACDriver.h next >
Encoding:
C/C++ Source or Header  |  1997-01-29  |  7.2 KB  |  243 lines  |  [TEXT/CWIE]

  1. #define DMABufferBase (Ptr) 0x61000000
  2.  
  3. #define    AMICSlotIER                    0x50F26012
  4.  
  5. #define    AMICSoundOutDMA                0x50F14018
  6. #define    AMICSoundInDMA                0x50F14014
  7.  
  8. #define    AMICCodecCtl0                0x50F14000
  9. #define    AMICCodecCtl1                0x50F14001
  10. #define    AMICCodecCtl2                0x50F14002
  11.  
  12. #define    kCommand                    0x40                // Command bit, when in Awacs mode
  13. #define    kExpand                        0x80                // Expand bit, when in Awacs mode
  14.  
  15. #define kHeadphonesInserted            0x08                // bit in AMICCodecStatus2
  16.  
  17. #define    AMICCodecStatus0            0x50F14004
  18. #define    AMICCodecStatus1            0x50F14005
  19. #define    AMICCodecStatus2            0x50F14006
  20.  
  21. #define    AMICPhase0                    0x50F1400C
  22. #define    AMICPhase1                    0x50F1400D
  23. #define    AMICPhase2                    0x50F1400E
  24.  
  25. #define    AMICSndCtl0                    0x50F14010
  26. #define kSndOutDMAEnable            0x01                // bit to enable/disable DMA sound out
  27. #define    AMICSndCtl1                    0x50F14011
  28.  
  29. #define    AMICSndBufSizeHi            0x50F14008
  30. #define    AMICSndBufSizeLo            0x50F14009
  31.  
  32. #define    kBuf0Offset                    0x00010000
  33. #define    kBuf1Offset                    0x00012000
  34.  
  35. #define    AMICVIADataB                0x50F00000            // used for a short delay...
  36.  
  37. // Our interrupt vector bit - defined in Internal:Asm:DMAMgrEqu.a in SuperMario.
  38.  
  39. #define        hwAmicSOUT            9                        // Sound Out
  40.  
  41. #define        kInstall            0                        // for _DMAIntInstall
  42. #define        kRemove                1
  43.  
  44. #define    kAwacsSignature                'JoeB'            //JoeB
  45. #define hwAmicSOUT                    9
  46.  
  47. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  48. //    Macros
  49. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  50.  
  51. // turn a byte count into a sample count (assuming 16 bit stereo)
  52. #define BytesToSamples(bytes)    (bytes >> 2)
  53.  
  54. // turn a sample count into a byte count (assuming 16 bit stereo)
  55. #define SamplesToBytes(samples)    (samples << 2)
  56.  
  57.  
  58. // Can't spinloop on AMIC2, need the worst-case delay
  59.  
  60. #if forPDMProto
  61. #define    ProtoDelay                                                        \
  62.         if (!(globals->AMIC3)) {                                        \
  63.             Delay(10, (long *)&globals->finalTicks);                    \
  64.             *(unsigned char *)AMICCodecCtl0 = kCommand;                    \
  65.             }
  66. #else
  67. #define    ProtoDelay    ;
  68. #endif
  69.  
  70.  
  71. // Write curR1 to Awacs.
  72. // (Register numbers (0,1,2,4) are pre-stuffed into hi nybble of shadow.)
  73.  
  74. #define    WRITE_AWACS_REG_1                                                                                \
  75.         WaitExpandClear(globals);                                        /* wait til it's safe        */    \
  76.         *(unsigned char *)AMICCodecCtl0 = kCommand;                                                        \
  77.         *(unsigned char *)AMICCodecCtl1 = (curR1 >> 8);                    /* reg 1, [11:8]            */    \
  78.         *(unsigned char *)AMICCodecCtl2 = curR1;                        /* [7:0]                    */    \
  79.         *(unsigned char *)AMICCodecCtl0 = kExpand | kCommand;            /* Set Expand                */    \
  80.         ProtoDelay;
  81.  
  82. // Write curR2 to Awacs.
  83. // (Register numbers (0,1,2,4) are pre-stuffed into hi nybble of shadow.)
  84.  
  85. #define    WRITE_AWACS_REG_2                                                                                \
  86.         WaitExpandClear(globals);                                        /* wait til it's safe        */    \
  87.         *(unsigned char *)AMICCodecCtl0 = kCommand;                                                        \
  88.         *(unsigned char *)AMICCodecCtl1 = (curR2 >> 8);                    /* reg 2, [11:8]            */    \
  89.         *(unsigned char *)AMICCodecCtl2 = curR2;                        /* [7:0]                    */    \
  90.         *(unsigned char *)AMICCodecCtl0 = kExpand | kCommand;            /* Set Expand                */    \
  91.         ProtoDelay;
  92.  
  93. // Write curR4 to Awacs.
  94. // (Register numbers (0,1,2,4) are pre-stuffed into hi nybble of shadow.)
  95.  
  96. #define    WRITE_AWACS_REG_4                                                                                \
  97.         WaitExpandClear(globals);                                        /* wait til it's safe        */    \
  98.         *(unsigned char *)AMICCodecCtl0 = kCommand;                                                        \
  99.         *(unsigned char *)AMICCodecCtl1 = (curR4 >> 8);                    /* reg 4, [11:8]            */    \
  100.         *(unsigned char *)AMICCodecCtl2 = curR4;                        /* [7:0]                    */    \
  101.         *(unsigned char *)AMICCodecCtl0 = kExpand | kCommand;            /* Set Expand                */    \
  102.         ProtoDelay;
  103.  
  104.  
  105. //    AMIC Control Macros
  106.  
  107. // --------------
  108. // Macros for dealing with Sound DMA interrupts.
  109.  
  110. #define    CLEAR_SND_OUT_IF1                                \
  111.                 *(unsigned char *)AMICSoundOutDMA |= 0x80
  112.  
  113. #define    CLEAR_SND_OUT_IF0                                \
  114.                 *(unsigned char *)AMICSoundOutDMA |= 0x40
  115.  
  116. #define    CLEAR_SND_OUT_BUF_INTS                            \
  117.                 *(unsigned char *)AMICSoundOutDMA |= 0xC0
  118.  
  119. #define    CLEAR_UNDERRUN_INT                                \
  120.                 *(unsigned char *)AMICSoundOutDMA |= 0x20
  121.  
  122. #define    ENABLE_IF1_INT                                    \
  123.                 *(unsigned char *)AMICSoundOutDMA |= 0x08
  124.  
  125. #define    DISABLE_IF1_INT                                    \
  126.                 *(unsigned char *)AMICSoundOutDMA &= ~0x08
  127.  
  128. #define    SND_OUT_IF1                                        \
  129.                 ((*(unsigned char *)AMICSoundOutDMA) & 0x80)
  130.  
  131. #define    ENABLE_IF0_INT                                    \
  132.                 *(unsigned char *)AMICSoundOutDMA |= 0x04
  133.  
  134. #define    DISABLE_IF0_INT                                    \
  135.                 *(unsigned char *)AMICSoundOutDMA &= ~0x04
  136.  
  137. #define    SND_OUT_IF0                                        \
  138.                 ((*(unsigned char *)AMICSoundOutDMA) & 0x40)
  139.  
  140. #define    SND_OUT_UNDERRUN                                \
  141.                 ((*(unsigned char *)AMICSoundOutDMA) & 0x20)
  142.  
  143.  
  144. #define    ENABLE_BUF_AND_UNDERRUN_INTS                    \
  145.                 *(unsigned char *)AMICSoundOutDMA |= 0x0E
  146.  
  147. #define    DISABLE_BUF_AND_UNDERRUN_INTS                    \
  148.                 *(unsigned char *)AMICSoundOutDMA &= ~0x0E
  149.  
  150. // --------------
  151. // Macros to start/stop sound out DMA
  152.  
  153. #define    SND_OUT_DMA_ENABLE                                \
  154.                 *(unsigned char *)AMICSndCtl0 |= kSndOutDMAEnable
  155.  
  156. #define    SND_OUT_DMA_DISABLE                                \
  157.                 *(unsigned char *)AMICSndCtl0 &= ~kSndOutDMAEnable
  158.  
  159. // --------------
  160. // Macro to see if sound out DMA is running
  161.  
  162. #define    SND_OUT_DMA_RUNNING                                                    \
  163.                 ( (*(unsigned char *)AMICSndCtl0) & kSndOutDMAEnable )
  164.  
  165. // --------------
  166. // Macros to start/stop sound in DMA
  167.  
  168. #define    SND_IN_DMA_ENABLE                                                    \
  169.                 *(unsigned char *)AMICSndCtl1 |= 0x80
  170.  
  171. #define    SND_IN_DMA_DISABLE                                                    \
  172.                 *(unsigned char *)AMICSndCtl1 &= ~0x80
  173.  
  174. // --------------
  175. // Macro to see if sound in DMA is running
  176.  
  177. #define    SND_IN_DMA_RUNNING                                                    \
  178.                 ( (*(unsigned char *)AMICSndCtl1) & 0x80 )
  179.  
  180. // --------------
  181. // Macros to set the sample rate
  182.  
  183. #define    SET_RATE_44_1                                                         \
  184.                 *(unsigned char *)AMICSndCtl0 =                             \
  185.                         (((*(unsigned char *)AMICSndCtl0) & 0xF9) | 0x04);
  186.  
  187. #define    SET_RATE_29_4                                                         \
  188.                 *(unsigned char *)AMICSndCtl0 =                             \
  189.                         (((*(unsigned char *)AMICSndCtl0) & 0xF9) | 0x02);
  190.  
  191. #define    SET_RATE_22_05                                                         \
  192.                 *(unsigned char *)AMICSndCtl0 =                             \
  193.                         ((*(unsigned char *)AMICSndCtl0) & 0xF9);
  194.  
  195. #define    SET_HW_RATE(rate)                                                    \
  196.                 *(unsigned char *)AMICSndCtl0 =                             \
  197.                         (((*(unsigned char *)AMICSndCtl0) & 0xF9) | rate);
  198.  
  199. // --------------
  200. // Macros to get the sample rate
  201.  
  202. #define    GET_HW_RATE                                                            \
  203.                 (*(unsigned char *)AMICSndCtl0)
  204.  
  205. #define    RATE_IS_44_1                                                        \
  206.                 ((*(unsigned char *)AMICSndCtl0) & 0x06) == 0x04
  207.  
  208. #define    RATE_IS_29_4                                                        \
  209.                 ((*(unsigned char *)AMICSndCtl0) & 0x06) == 0x02
  210.  
  211. #define    RATE_IS_22_05                                                        \
  212.                 ((*(unsigned char *)AMICSndCtl0) & 0x06) == 0x00
  213.  
  214. // --------------
  215. // Misc Macros
  216.  
  217. #define    SET_OUTPUT_SUBFRAME_0                                                \
  218.                 *(unsigned char *)AMICSndCtl1 =                             \
  219.                         (((*(unsigned char *)AMICSndCtl1) & 0xC3) | 0x04)
  220.  
  221. #define    SET_BUF_SIZE(size)                                                    \
  222.                 *(unsigned char *)AMICSndBufSizeHi = (size >> 8);            \                                        \
  223.                 *(unsigned char *)AMICSndBufSizeLo = size
  224.  
  225. #define    GET_BUF_SIZE_HI                                                        \
  226.                 *(unsigned char *)AMICSndBufSizeHi
  227.  
  228. #define    GET_BUF_SIZE_LO                                                        \
  229.                 *(unsigned char *)AMICSndBufSizeLo
  230.  
  231. #define    SET_BUF_SIZE_HI(size)                                                \
  232.                 *(unsigned char *)AMICSndBufSizeHi = size;
  233.  
  234. #define    SET_BUF_SIZE_LO(size)                                                \
  235.                 *(unsigned char *)AMICSndBufSizeLo = size;
  236.  
  237. #define    MATCH_BUF_SIZE(size)                                                \
  238.                 ( (*(unsigned char *)AMICSndBufSizeHi == (unsigned char)(size >> 8)) && \
  239.                   (*(unsigned char *)AMICSndBufSizeLo == (unsigned char)size) )
  240.  
  241. #define    GET_DMA_BUF_BASE                                                    \
  242.                 0x61000000
  243.